#@layout("订阅RSS管理") #define selectform() #end #define main()
<fieldset class="layui-elem-field">
	<legend>订阅RSS管理 </legend>
	<div style="width: 120em; overflow: auto;">
		<div class="layui-field-box layui-form"> 
			<table class="layui-table admin-table">
				<thead>
					<tr>
						<th style="width: 30px;"><input type="checkbox"
							lay-filter="allselector" lay-skin="primary"></th>
						<th>我的类型</th>
						<th>频道序号</th>
						<th>频道名</th>
						<th>作者</th>
						<th>发布时间</th>
						<th>URL</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="content">
				</tbody>
				<tfoot>
					<tr>
						<th colspan="8 ">
							<div class="admin-table-page">
								<div id="paged" class="page"></div>
							</div>
						</th>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
</fieldset>
#end #define js()
<!--模板-->
<script type="text/html" id="tpl">
			{{# layui.each(d.list.list, function(index, item){ }}
			<tr>
				<td><input type="checkbox" lay-skin="primary"></td>
				<td>{{ item.typename}}</td>
				<td>{{ item.id}}</td>
				<td>{{ item.name }}</td>
				<td>{{ item.cuser }}</td>
				<td>{{ item.ctime }}</td>
				<td>#(session.basepath ?? ){{ item.url }}</td>
				<td><a href="javascript:;" data-name='{{ item.id }}' data-opt="edit" class="layui-btn layui-btn-mini">退订</a></td>
			</tr>
			{{# }); }}
		</script>
<script type="text/javascript">

			layui.config({
				base: 'js/'
			});
			layui.use(['paging', 'form', 'laydate', 'upload'], function() {
			var $ = layui.jquery,
				paging = layui.paging(),
				layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
				layer = layui.layer, //获取当前窗口的layer对象
				form = layui.form();


			var data = {};
			var loadtab = function(data){ 
			paging.init({
				url: 'cha/mychannels',  //地址
				elem: '#content', //内容容器
				params: data,
				type: 'post',
				tempElem: '#tpl', //模块容器
				pageConfig: { //分页参数配置
					elem: '#paged', //分页容器
					pageSize: 10 //分页大小
				},
				success: function() { //渲染成功的回调
					//alert('渲染成功');
				},
				fail: function(msg) { //获取数据失败的回调
					//alert('获取数据失败')
				},
				complate: function() { //完成的回调
					//alert('处理完成');
					//重新渲染复选框
					form.render('checkbox');
					form.on('checkbox(allselector)', function(data) {
						var elem = data.elem;

						$('#content').children('tr').each(function() {
							var $that = $(this);
							//全选或反选
							$that.children('td').eq(0).children('input[type=checkbox]')[0].checked = elem.checked;
							form.render('checkbox');
						});
					});

					//绑定所有edit按钮事件						
					$('#content').children('tr').each(function() {
						var $that = $(this);
						$that.children('td:last-child').children('a[data-opt=edit]').on('click', function() {
							var cid = $(this).data('name');
							$.ajax({
								type: 'post',
								url:  'cha/UNSubscribe',
								async: false,
								data: {channel_id: cid },
								dataType: 'json',
								success: function(ret, status, xhr) {
									
									if(ret.isOk){
										layer.msg(ret.msg);
										location.reload();
									}else{
										layer.msg(ret.msg);
									}
							  }
					    	 });							
							
							
							});
					});
				}
			});
			};
			loadtab(data);
			});
			
		</script>
#end

